<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<label>
    文本框:
    <input type="text">
</label>

<script>
    const inputElement = document.querySelector('input');
    inputElement.addEventListener('keydown', function () {
        console.log('键盘按键按下了...')
    })
    inputElement.addEventListener('keyup', function () {
        console.log('键盘按键弹起了...')
    })
</script>
</body>
</html>